<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("devildark", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));

    $deviceid_query = mysql_query("select DISTINCT deviceid,RegisterDate from devildark "); //id
    //$deviceid = mysql_fetch_array($deviceid_query);
    //while($deviceid[deviceid])

while($deviceid = mysql_fetch_array($deviceid_query))
{
   mysql_query("REPLACE INTO deviceid (deviceid,RegisterDate) 
                    VALUES('$deviceid[deviceid]','$deviceid[RegisterDate]')") or die(mysql_error());
}

  // {
    //$first_query = mysql_query("SELECT RegisterDate FROM devildark where deviceid = '$deviceid[deviceid]' limit 0,1 ");

   // $first = mysql_fetch_array($first_query);
   mysql_query("update devildark a1 inner join deviceid a2 using(deviceid) set a1.RegisterDate =a2.RegisterDate where a1.deviceid =  a2.deviceid");
  //var_dump($deviceid[deviceid]);die;
//
  // }

//mysql_query("delete from devildark where TotalExp = ''");
mysql_close($con);
?>